package com.inspinia.upms.common.listener;

import com.inspinia.base.cache.RedisUtil;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.SessionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ShiroSessionListener implements SessionListener {

    protected Logger logger = LoggerFactory.getLogger(ShiroSessionListener.class);

    @Override
    public void onStart(Session session) {
        logger.debug("===================>session已创建===============>",session.getId());
    }

    @Override
    public void onStop(Session session) {
        RedisUtil.delete(session.getId().toString());
        logger.debug("===================>session已销毁===============>",session.getId());
    }

    @Override
    public void onExpiration(Session session) {
        RedisUtil.delete(session.getId().toString());
        logger.debug("===================>session已过期===============>",session.getId());
    }
}
